package com.example.back.dao.pay;

import com.example.back.bean.PayInfo;
import com.example.back.bean.YPayOrder;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;
import java.util.Map;

@Mapper
public interface RechargeInfoDao {
    @Select("select userId,userName,orderId,createTime,amount,status,details from p_pay_order order by createTime desc ")
    public List<YPayOrder> getPayRechargeInfoDao();

    @Select("select userId,userName,orderId,createTime,amount,status,details from p_pay_order where status = #{state} order by createTime desc ")
    public List<YPayOrder> getPayStateRechargeInfoDao(int state);

    @Select("select userId,userName,orderId,createTime,amount,status,details from p_pay_order where status = 1 and createTime BETWEEN #{startTime} and #{endTime} order by createTime desc ")
    public List<YPayOrder> getRechargeInfoDaoByTime(Date startTime,Date endTime);

    @Select("select userId,userName,orderId,createTime,amount,status,details from p_pay_order where status = #{state}  order by createTime desc")
    public List<YPayOrder> getPayStateInfoDao(int state);

    @Select("select userId,userName,orderId,createTime,amount,status,details from p_pay_order where status = #{state} and userId=#{userId} order by createTime desc")
    public List<YPayOrder> getOnePayStateInfoDao(int state,long userId);

    @Select("select sum(amount) from p_pay_order where status = 1 order by createTime desc ")
    public int getPaySuccessMoney();

    @Select("select userId,userName,orderId,createTime,amount,status,details from p_pay_order where  userId=#{userId} order by createTime desc")
    public List<YPayOrder> getOneUserPayMoney(long userId);

    @Select("select userId,userName,orderId,createTime,amount,status,details from p_pay_order where  userId like concat(#{userId},'%') and status=#{state} order by createTime desc")
    public List<YPayOrder> getOneUserPayStateMoney(long userId, int state);

    @Select("select sum(amount) from p_pay_order where  userId=#{userId} and status =1")
    public int getOneUserPayMoneyCount(long userId);
}
